<?php
namespace app\index\controller;
use app\common\controller\Api;

class LogIncome extends Api
{

    /**
     * @var \app\index\model\LogIncome
     */
    protected $model = null;

    public $relationSearchArr = ['user', 'channel'];

    public $state_num_to_text = [
        'type'=>[
            1=>'订单收入',
            2=>'分享收入',
            3=>'红包收入',
            4=>'提现中',
            5=>'提现失败',
            6=>'提现成功'
        ]
    ];

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('LogIncome');
    }

    public function pay(){
        
        $this->success('success', 1);
    }

    public function _condition($condition){
        $filer_arr = [];
        $op_arr = [];

        $condition['channel_id'] = $this->request->param('channel_id');
        $condition['user_id'] = $this->request->param('user_id');
        $condition['type'] = $this->request->param('type');
        $condition['start_create_time'] = $this->request->param('start_create_time');
        $condition['end_create_time'] = $this->request->param('end_create_time');

        if($condition['channel_id']){
            $filer_arr['channel_id'] = $condition['channel_id'];
        }
        if($condition['user_id']){
            $filer_arr['user_id'] = $condition['user_id'];
        }
        if(strlen($condition['type'])>0){
            $filer_arr['type'] = $condition['type'];
        }
        if($condition['start_create_time'] || $condition['end_create_time']){
            $filer_arr['create_time'] = $condition['start_create_time'].','.$condition['end_create_time'];
            $op_arr['create_time'] = 'BETWEEN'; 
        }
        return array($filer_arr, $op_arr);
    }
}
